<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //含有迭代器的有 Array Set Map String arguments NodeList
        let arr=['aaa','bbb','vvv']
        for(i of arr){
            console.log(i)
        }
        for(i in arr){
            console.log(i)
        }
        function aa(){
            console.log(arguments)
        }
        aa(1,2,3)
        let ss=arr[Symbol.iterator]()
        console.log(ss)
        console.log(arr)
        // 迭代器写在对象中(对象本身没有迭代器)
        let obj={
            name:'xcy',
            age:123,
            list:['123','234','345'],
            [Symbol.iterator](){
                let index=0
                return {
                    next:()=>{
                        return {value:this.list[index++],done:index===this.list.length+1?true:false}
                    }
                }
            }
        }
        for(i of obj){
            console.log(i)
        }
        console.log(...obj)
    </script>
</body>
</html>